Skip to content

feat: add swagger-ui for lake#1900

Merged
warren830 merged 11 commits into
apache:mainfrom
xgdyp:swagger-ui
May 19, 2022
Merged

feat: add swagger-ui for lake#1900
warren830 merged 11 commits into
apache:mainfrom
xgdyp:swagger-ui

Conversation

@xgdyp
Copy link
Copy Markdown
Contributor

@xgdyp xgdyp commented May 17, 2022

Summary

Key Points

  • This is a breaking change
  • New or existing documentation is updated

Description

This is a Draft PR for checking my work of adding swagger-ui is OK and I've finished most of the work except for polishing the description of each annotation.

Using swagger-ui, first, we need to install swag cli by

$ go get -u github.com/swaggo/swag/cmd/swag

also , we need to add swag cli to the path

and also need two package

# gin-swagger  is  a middleware package
$ go get github.com/swaggo/gin-swagger
# swagger  is an inner-config package
$ go get github.com/swaggo/gin-swagger/swaggerFiles

these have been written in go.mod.

My work is adding annotations to /api directory. In api.go,we need to do some basic settings and register swagger router.
In Controler Files, we also need to add annotations for each function.

After that , run swag init --parseDependency --parseInternal -o ./api/docs -g ./api/api.go to generate swag-docs.
--parseDependency --parseInternal aims to find models outside file. -o ./api/docs sets the generated docs in ./api/dos directory and -g ./api/api.go make swagger search api.go as an Enterance.

the command will generate three files as docs.go , swagger.json and swagger.yaml . These files are generated autoly
and can be ignored in formal version by using CI/CD tools.

Then we can see swagger page by enter URL http://localhost:8080/swagger/index.html#/. like
image

In API we can see the input format and output format.
image

We can also try your own input data in this page.

image

Does this close any open issues?

related to #292

Current Behavior

finish most of this feat

New Behavior

continue processing the description.

Screenshots

Include any relevant screenshots here.

Other Information

Any other information that is important to this PR.

@klesh
Copy link
Copy Markdown
Contributor

klesh commented May 18, 2022

This is an excellent implematation!

Copy link
Copy Markdown
Contributor

@warren830 warren830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!
LGTM

@xgdyp xgdyp marked this pull request as ready for review May 19, 2022 13:25
@xgdyp
Copy link
Copy Markdown
Contributor Author

xgdyp commented May 19, 2022

ready for review!

@xgdyp xgdyp requested a review from warren830 May 19, 2022 13:33
Copy link
Copy Markdown
Contributor

@warren830 warren830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job!
Keep going!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants